home *** CD-ROM | disk | FTP | other *** search
/ Supercompiler 1997 / SUPERCOMPILER97.iso / Delphi 3.0 / DATA.Z / imagehlp.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1997-01-29  |  24.0 KB  |  569 lines

  1. {*******************************************************}
  2. {                                                       }
  3. {       Delphi Run-time Library                         }
  4. {       Prototypes and constants required for the       }
  5. {       Win32 image help routines.                      }
  6. {                                                       }
  7. {       Copyright (c) 1996 Borland International        }
  8. {                                                       }
  9. {*******************************************************}
  10.  
  11. unit Imagehlp;
  12.  
  13. interface
  14.  
  15. uses Windows;
  16.  
  17. { Define checksum return codes. }
  18. const
  19.   CHECKSUM_SUCCESS                = 0;
  20.   CHECKSUM_OPEN_FAILURE           = 1; 
  21.   CHECKSUM_MAP_FAILURE            = 2;
  22.   CHECKSUM_MAPVIEW_FAILURE        = 3;
  23.   CHECKSUM_UNICODE_FAILURE        = 4;
  24.  
  25. { Define Splitsym flags. }
  26.  
  27.   SPLITSYM_REMOVE_PRIVATE         = $00000001;      { Remove CV types/symbols and Fixup debug }
  28. {  Used for creating .dbg files that ship }
  29. {  as part of the product. }
  30.  
  31.   SPLITSYM_EXTRACT_ALL            = $00000002;      { Extract all debug info from image. }
  32. {  Normally, FPO is left in the image }
  33. {  to allow stack traces through the code. }
  34. {  Using this switch is similar to linking }
  35. {  with -debug:none except the .dbg file }
  36. {  exists... }
  37.  
  38. { Define checksum function prototypes. }
  39. function CheckSumMappedFile(BaseAddress: Pointer; FileLength: DWORD;
  40.   HeaderSum: PDWORD; CheckSum: PDWORD): PImageNtHeaders;
  41.  
  42. function MapFileAndCheckSumA(Filename: PAnsiChar; var HeaderSum, CheckSum: DWORD): DWORD;
  43. function MapFileAndCheckSumW(Filename: PWideChar; var HeaderSum, CheckSum: DWORD): DWORD;
  44. function MapFileAndCheckSum(Filename: PChar; var HeaderSum, CheckSum: DWORD): DWORD;
  45.  
  46.  
  47. function TouchFileTimes(FileHandle: THandle; const lpSystemTime: TSystemTime): Bool;
  48.  
  49. function SplitSymbols(ImageName, SymbolsPath, SymbolFilePath: LPSTR;
  50.   Flags: DWORD): Bool;
  51.  
  52. function FindDebugInfoFile(FileName, SymbolPath, DebugFilePath: LPSTR): THandle;
  53.  
  54. function FindExecutableImage(FileName, SymbolPath, ImageFilePath: LPSTR): THandle;
  55.  
  56. function UpdateDebugInfoFile(ImageFileName, SymbolPath, DebugFilePath: LPSTR;
  57.   NtHeaders: PImageNtHeaders): Bool;
  58.  
  59. function UpdateDebugInfoFileEx(ImageFileName, SymbolPath, DebugFilePath: LPSTR;
  60.   NtHeaders: PImageNtHeaders; OldChecksum: DWORD): Bool;
  61.  
  62. function BindImage(ImageName, DllPath, SymbolPath: LPSTR): Bool;
  63.  
  64. type
  65.   TImagehlpStatusReason = (
  66.     BindOutOfMemory,
  67.     BindRvaToVaFailed,
  68.     BindNoRoomInImage,
  69.     BindImportModuleFailed,
  70.     BindImportProcedureFailed,
  71.     BindImportModule,
  72.     BindImportProcedure,
  73.     BindForwarder,
  74.     BindForwarderNOT,
  75.     BindImageModified,
  76.     BindExpandFileHeaders,
  77.     BindImageComplete,
  78.     BindMismatchedSymbols,
  79.     BindSymbolsNotUpdated
  80.   );
  81.  
  82. type
  83.   TImagehlpStatusRoutine = function(Reason: TImagehlpStatusReason;
  84.     ImageName, DllName: LPSTR; Va, Parameter: ULONG): Bool;
  85.  
  86.  
  87. function BindImageEx(Flags: DWORD; ImageName, DllPath, SymbolPath: LPSTR;
  88.   var StatusRoutine: TImagehlpStatusReason): Bool;
  89.  
  90. const
  91.   BIND_NO_BOUND_IMPORTS     = $00000001;
  92.   BIND_NO_UPDATE            = $00000002;
  93.   BIND_ALL_IMAGES           = $00000004;
  94.  
  95. function ReBaseImage(CurrentImageName, SymbolPath: LPSTR; fReBase,
  96.   fRebaseSysfileOk, fGoingDown: Bool; CheckImageSize: ULONG;
  97.   var OldImageSize, OldImageBase, NewImageSize, NewImageBase: ULONG;
  98.   TimeStamp: ULONG): Bool;
  99.  
  100. const
  101.   IMAGE_SEPARATION     = 64 * 1024;
  102.  
  103. type
  104.   PloadedImage = ^LoadedImage;
  105.   LoadedImage = packed record
  106.     ModuleName: LPSTR;
  107.     hFile: THandle;
  108.     MappedAddress: PChar;
  109.     FileHeader: PImageNtHeaders;
  110.     LastRvaSection: PImageSectionHeader;
  111.     NumberOfSections: ULONG;
  112.     Sections: PImageSectionHeader;
  113.     Characteristics: ULONG;
  114.     fSystemImage: ByteBool;
  115.     fDOSImage: ByteBool;
  116.     Links: TListEntry;
  117.     SizeOfImage: ULONG;
  118.   end;
  119.  
  120.  
  121. function ImageLoad(DllName, DllPath: LPSTR): PLoadedImage;
  122.  
  123. function ImageUnload(LoadedImage: PLoadedImage): Bool;
  124.  
  125. function ImageNtHeader(Base: Pointer): PImageNtHeaders;
  126.  
  127. function ImageDirectoryEntryToData(Base: Pointer; MappedAsImage: ByteBool;
  128.   DirectoryEntry: Word; var Size: ULONG): Pointer;
  129.  
  130. function ImageRvaToSection(NtHeaders: PImageNtHeaders; Base: Pointer;
  131.   Rva: ULONG): PImageSectionHeader;
  132.  
  133. function ImageRvaToVa(NtHeaders: PImageNtHeaders; Base: Pointer;
  134.   Rva: ULONG; var LastRvaSection: PImageSectionHeader): Pointer;
  135.  
  136. function MapAndLoad(ImageName, DllPath: LPSTR; LoadedImage: PLoadedImage;
  137.   DotDll, ReadOnly: Bool): Bool;
  138.  
  139. function GetImageConfigInformation(LoadedImage: PLoadedImage;
  140.   var ImageConfigInformation: TImageLoadConfigDirectory): Bool;
  141.  
  142. function GetImageUnusedHeaderBytes(LoadedImage: PLoadedImage;
  143.   var SizeUnusedHeaderBytes: DWORD): DWORD;
  144.  
  145. function SetImageConfigInformation(LoadedImage: PLoadedImage;
  146.   const ImageConfigInformation: TImageLoadConfigDirectory): Bool;
  147.  
  148. function UnMapAndLoad(LoadedImage: PLoadedImage): Bool;
  149.  
  150. type
  151.   PimageDebugInformation = ^TImageDebugInformation;
  152.   TImageDebugInformation = packed record
  153.     List: TListEntry;
  154.     Size: DWORD;
  155.     MappedBase: Pointer;
  156.     Machine: Word;
  157.     Characteristics: Word;
  158.     CheckSum: DWORD;
  159.     ImageBase: DWORD;
  160.     SizeOfImage: DWORD;
  161.     NumberOfSections: DWORD;
  162.     Sections: PImageSectionHeader;
  163.     ExportedNamesSize: DWORD;
  164.     ExportedNames: LPSTR;
  165.     NumberOfFunctionTableEntries: DWORD;
  166.     FunctionTableEntries: PImageFunctionEntry;
  167.     LowestFunctionStartingAddress: DWORD;
  168.     HighestFunctionEndingAddress: DWORD;
  169.     NumberOfFpoTableEntries: DWORD;
  170.     FpoTableEntries: PFpoData;
  171.     SizeOfCoffSymbols: DWORD;
  172.     CoffSymbols: PImageCOFFSymbolsHeader;
  173.     SizeOfCodeViewSymbols: DWORD;
  174.     CodeViewSymbols: Pointer;
  175.     ImageFilePath: LPSTR;
  176.     ImageFileName: LPSTR;
  177.     DebugFilePath: LPSTR;
  178.     TimeDateStamp: DWORD;
  179.     RomImage: Bool;
  180.     DebugDirectory: PImageDebugDirectory;
  181.     NumberOfDebugDirectories: DWORD;
  182.     Reserved: packed array[0..2] of DWORD;
  183.   end;
  184.  
  185. function MapDebugInformation(FileHandle: THandle; FileName, SymbolPath: LPSTR;
  186.   ImageBase: DWORD): PImageDebugInformation;
  187.  
  188. function UnmapDebugInformation(DebugInfo: PImageDebugInformation): Bool;
  189.  
  190. function SearchTreeForFile(RootPath, InputPathName, OutputPathBuffer: LPSTR): Bool;
  191.  
  192. function MakeSureDirectoryPathExists(DirPath: LPCSTR): Bool;
  193.  
  194. { UnDecorateSymbolName Flags }
  195. const
  196.   UNDNAME_COMPLETE                     = $0000;    { Enable full undecoration }
  197.   UNDNAME_NO_LEADING_UNDERSCORES       = $0001;    { Remove leading underscores from MS extended keywords }
  198.   UNDNAME_NO_MS_KEYWORDS               = $0002;    { Disable expansion of MS extended keywords }
  199.   UNDNAME_NO_FUNCTION_RETURNS          = $0004;    { Disable expansion of return type for primary declaration }
  200.   UNDNAME_NO_ALLOCATION_MODEL          = $0008;    { Disable expansion of the declaration model }
  201.   UNDNAME_NO_ALLOCATION_LANGUAGE       = $0010;    { Disable expansion of the declaration language specifier }
  202.   UNDNAME_NO_MS_THISTYPE               = $0020;    { NYI Disable expansion of MS keywords on the 'this' type for primary declaration }
  203.   UNDNAME_NO_CV_THISTYPE               = $0040;    { NYI Disable expansion of CV modifiers on the 'this' type for primary declaration }
  204.   UNDNAME_NO_THISTYPE                  = $0060;    { Disable all modifiers on the 'this' type }
  205.   UNDNAME_NO_ACCESS_SPECIFIERS         = $0080;    { Disable expansion of access specifiers for members }
  206.   UNDNAME_NO_THROW_SIGNATURES          = $0100;    { Disable expansion of 'throw-signatures' for functions and pointers to functions }
  207.   UNDNAME_NO_MEMBER_TYPE               = $0200;    { Disable expansion of 'static' or 'virtual'ness of members }
  208.   UNDNAME_NO_RETURN_UDT_MODEL          = $0400;    { Disable expansion of MS model for UDT returns }
  209.   UNDNAME_32_BIT_DECODE                = $0800;    { Undecorate 32-bit decorated names }
  210.   UNDNAME_NAME_ONLY                    = $1000;    { Crack only the name for primary declaration; }
  211. {  return just [scope::]name.  Does expand template params }
  212.   UNDNAME_NO_ARGUMENTS                 = $2000;    { Don't undecorate arguments to function }
  213.   UNDNAME_NO_SPECIAL_SYMS              = $4000;    { Don't undecorate special names (v-table, vcall, vector xxx, metatype, etc) }
  214.  
  215. function UnDecorateSymbolName(DecoratedName, UnDecoratedName: LPSTR;
  216.   UndecoratedLength, Flags: DWORD): DWORD;
  217.  
  218.  
  219. { StackWalking API }
  220. type
  221.   TAddressMode = (
  222.     AddrMode1616,
  223.     AddrMode1632,
  224.     AddrModeReal,
  225.     AddrModeFlat
  226.   );
  227.  
  228.   PAddress = ^TAddress;
  229.   TAddress = packed record
  230.     Offset: DWORD;
  231.     Segment: Word;
  232.     Mode: TAddressMode;
  233.   end;
  234.  
  235. { This structure is included in the STACKFRAME structure, }
  236. { and is used to trace through usermode callbacks in a thread's }
  237. { kernel stack.  The values must be copied by the kernel debugger }
  238. { from the DBGKD_GET_VERSION and WAIT_STATE_CHANGE packets. }
  239.  
  240.   PKdHelp = ^TKdHelp;
  241.   TKdHelp = packed record { address of kernel thread object, as provided }
  242.                           { in the WAIT_STATE_CHANGE packet. }
  243.     Thread: DWORD;
  244.     { offset in thread object to pointer to the current callback frame }
  245.     { in kernel stack. }
  246.     ThCallbackStack: DWORD;
  247.     { offsets to values in frame: }
  248.     { address of next callback frame }
  249.     NextCallback: DWORD;
  250.     { address of saved frame pointer (if applicable) }
  251.     FramePointer: DWORD;
  252.     { Address of the kernel function that calls out to user mode }
  253.     KiCallUserMode: DWORD;
  254.     { Address of the user mode dispatcher function }
  255.     KeUserCallbackDispatcher: DWORD;
  256.   end;
  257.  
  258.   PStackFrame = ^TStackFrame;
  259.   TStackFrame = packed record
  260.     AddrPC: TAddress;                  { program counter }
  261.     AddrReturn: TAddress;              { return address }
  262.     AddrFrame: TAddress;               { frame pointer }
  263.     AddrStack: TAddress;               { stack pointer }
  264.     FuncTableEntry: Pointer;          { pointer to pdata/fpo or NULL }
  265.     Params: packed array[0..3] of DWORD;{ possible arguments to the function }
  266.     _Far: Bool;                        { WOW far call }
  267.     _Virtual: Bool;                    { is this a virtual frame? }
  268.     Reserved: packed array[0..2] of DWORD;{ used internally by StackWalk api }
  269.     KdHelp: TKdHelp;
  270.   end;
  271.  
  272. type
  273.   TReadProcessMemoryRoutine = function(hProcess: THandle;
  274.     lpBaseAddress, lpBuffer: Pointer; nSize: DWORD;
  275.     var lpNumberOfBytesRead: DWORD): Bool;
  276.  
  277.   TFunctionTableAccessRoutine = function(hProcess: THandle;
  278.     AddrBase: DWORD): Pointer;
  279.  
  280.   TGetModuleBaseRoutine = function(hProcess: THandle;
  281.     ReturnAddress: DWORD): DWORD;
  282.  
  283.   TTranslateAddressRoutine = function(hProcess, hThread: THandle;
  284.     lpaddr: PAddress): DWORD;
  285.  
  286. function StackWalk(MachineType: DWORD; hProcess, hThread: THandle;
  287.   StackFrame: PStackFrame; ContextRecord: Pointer;
  288.   ReadMemoryRoutine: TReadProcessMemoryRoutine;
  289.   FunctionTableAccessRoutine: TFunctionTableAccessRoutine;
  290.   GetModuleBaseRoutine: TGetModuleBaseRoutine;
  291.   TranslateAddress: TTranslateAddressRoutine): Bool;
  292.  
  293. const
  294.   API_VERSION_NUMBER     = 5;
  295.  
  296. type
  297.   PApiVersion = ^TApiVersion;
  298.   TApiVersion = packed record
  299.     MajorVersion: Word;
  300.     MinorVersion: Word;
  301.     Revision: Word;
  302.     Reserved: Word;
  303.   end;
  304.  
  305. function ImagehlpApiVersion: PApiVersion;
  306.  
  307. function ImagehlpApiVersionEx(var AppVersion: TApiVersion): PApiVersion;
  308.  
  309. function GetTimestampForLoadedLibrary(Module: HMODULE): DWORD;
  310.  
  311. function RemovePrivateCvSymbolic(DebugData: PChar; var NewDebugData: PChar;
  312.   var NewDebugSize: ULONG): Bool;
  313.  
  314. procedure RemoveRelocations(ImageName: PChar);
  315.  
  316.  
  317. { typedefs for function pointers }
  318. type
  319.   TSymEnummodulesCallback = function(ModuleName: LPSTR; BaseOfDll: ULONG;
  320.     UserContext: Pointer): Bool;
  321.  
  322.   TSymEnumsymbolsCallback = function(SymbolName: LPSTR; SymbolAddress,
  323.     SymbolSize: ULONG; UserContext: Pointer): Bool;
  324.  
  325.   TEnumloadedModulesCallback = function(ModuleName: LPSTR; ModuleBase,
  326.     ModuleSize: ULONG; UserContext: Pointer): Bool;
  327.  
  328.   TSymbolRegisteredCallback = function(hProcess: THandle; ActionCode: ULONG;
  329.     CallbackData, UserContext: Pointer): Bool;
  330.  
  331.  
  332. { symbol flags }
  333. const
  334.   SYMF_OMAP_GENERATED       = $00000001;
  335.   SYMF_OMAP_MODIFIED        = $00000002;
  336.  
  337.  
  338. { symbol type enumeration }
  339. type
  340.   TSymType = (
  341.     SymNone,
  342.     SymCoff,
  343.     SymCv,
  344.     SymPdb,
  345.     SymExport,
  346.     SymDeferred,
  347.     SymSym                  { .sym file }
  348.   );
  349.  
  350. { symbol data structure }
  351.   PImagehlpSymbol = ^TImagehlpSymbol;
  352.   TImagehlpSymbol = packed record
  353.     SizeOfStruct: DWORD;                                { set to sizeof(IMAGEHLP_SYMBOL) }
  354.     Address: DWORD;                                     { virtual address including dll base address }
  355.     Size: DWORD;                                        { estimated size of symbol, can be zero }
  356.     Flags: DWORD;                                       { info about the symbols, see the SYMF defines }
  357.     MaxNameLength: DWORD;                               { maximum size of symbol name in 'Name' }
  358.     Name: packed array[0..0] of Char;                   { symbol name (null terminated string) }
  359.   end;
  360.  
  361.  
  362. { module data structure }
  363.   PImagehlpModule = ^TImagehlpModule;
  364.   TImagehlpModule = packed record
  365.     SizeOfStruct: DWORD;                                { set to sizeof(IMAGEHLP_MODULE) }
  366.     BaseOfImage: DWORD;                                 { base load address of module }
  367.     ImageSize: DWORD;                                   { virtual size of the loaded module }
  368.     TimeDateStamp: DWORD;                               { date/time stamp from pe header }
  369.     CheckSum: DWORD;                                    { checksum from the pe header }
  370.     NumSyms: DWORD;                                     { number of symbols in the symbol table }
  371.     SymType: TSymType;                                  { type of symbols loaded }
  372.     ModuleName: packed array[0..31] of Char;            { module name }
  373.     ImageName: packed array[0..255] of Char;            { image name }
  374.     LoadedImageName: packed array[0..255] of Char;      { symbol file name }
  375.   end;
  376.  
  377.  
  378. { data structures used for registered symbol callbacks }
  379. const
  380.   CBA_DEFERRED_SYMBOL_LOAD_START              = $00000001;
  381.   CBA_DEFERRED_SYMBOL_LOAD_COMPLETE           = $00000002;
  382.   CBA_DEFERRED_SYMBOL_LOAD_FAILURE            = $00000003;
  383.   CBA_SYMBOLS_UNLOADED                        = $00000004;
  384.   CBA_DUPLICATE_SYMBOL                        = $00000005;
  385.  
  386. type
  387.   PImagehlpDeferredSymbolLoad = ^TImagehlpDeferredSymbolLoad;
  388.   TImagehlpDeferredSymbolLoad = packed record
  389.     SizeOfStruct: DWORD;                                { set to sizeof(IMAGEHLP_DEFERRED_SYMBOL_LOAD) }
  390.     BaseOfImage: DWORD;                                 { base load address of module }
  391.     CheckSum: DWORD;                                    { checksum from the pe header }
  392.     TimeDateStamp: DWORD;                               { date/time stamp from pe header }
  393.     FileName: packed array[0..MAX_PATH-1] of Char;      { symbols file or image name }
  394.   end;
  395.  
  396.   PImagehlpDuplicateSymbol = ^TImagehlpDuplicateSymbol;
  397.   TImagehlpDuplicateSymbol = packed record
  398.     SizeOfStruct: DWORD;                                { set to sizeof(IMAGEHLP_DUPLICATE_SYMBOL) }
  399.     NumberOfDups: DWORD;                                { number of duplicates in the Symbol array }
  400.     Symbol: PImagehlpSymbol;                            { array of duplicate symbols }
  401.     SelectedSymbol: ULONG;                           { symbol selected (-1 to start) }
  402.   end;
  403.  
  404.  
  405.  
  406. { options that are set/returned by SymSetOptions() & SymGetOptions() }
  407. { these are used as a mask }
  408.  
  409. const
  410.   SYMOPT_CASE_INSENSITIVE      = $00000001;
  411.   SYMOPT_UNDNAME               = $00000002;
  412.   SYMOPT_DEFERRED_LOADS        = $00000004;
  413.   SYMOPT_NO_CPP                = $00000008;
  414.  
  415.  
  416. function SymSetOptions(SymOptions: DWORD): DWORD;
  417.  
  418. function SymGetOptions: DWORD;
  419.  
  420. function SymCleanup(hProcess: THandle): Bool;
  421.  
  422. function SymEnumerateModules(hProcess: THandle;
  423.   EnumModulesCallback: TSymEnumModulesCallback; UserContext: Pointer): Bool;
  424.  
  425. function SymEnumerateSymbols(hProcess: THandle; BaseOfDll: DWORD;
  426.   EnumSymbolsCallback: TSymEnumSymbolsCallback; UserContext: Pointer): Bool;
  427.  
  428. function EnumerateLoadedModules(hProcess: THandle;
  429.   EnumLoadedModulesCallback: TEnumLoadedModulesCallback;
  430.   UserContext: Pointer): Bool;
  431.  
  432. function SymFunctionTableAccess(hProcess: THandle; AddrBase: DWORD): Pointer;
  433.  
  434. function SymGetModuleInfo(hProcess: THandle; dwAddr: DWORD;
  435.   var ModuleInfo: TImagehlpModule): Bool;
  436.  
  437. function SymGetModuleBase(hProcess: THandle; dwAddr: DWORD): DWORD;
  438.  
  439. function SymGetSymFromAddr(hProcess: THandle; dwAddr: DWORD;
  440.   pdwDisplacement: PDWORD; var Symbol: TImagehlpSymbol): Bool;
  441.  
  442. function SymGetSymFromName(hProcess: THandle; Name: LPSTR;
  443.   var Symbol: TImagehlpSymbol): Bool;
  444.  
  445. function SymGetSymNext(hProcess: THandle; var Symbol: TImagehlpSymbol): Bool;
  446.  
  447. function SymGetSymPrev(hProcess: THandle; var Symbol: TImagehlpSymbol): Bool;
  448.  
  449. function SymInitialize(hProcess: THandle; UserSearchPath: LPSTR;
  450.   fInvadeProcess: Bool): Bool;
  451.  
  452. function SymGetSearchPath(hProcess: THandle; SearchPath: LPSTR;
  453.   SearchPathLength: DWORD): Bool;
  454.  
  455. function SymSetSearchPath(hProcess: THandle; SearchPath: LPSTR): Bool;
  456.  
  457. function SymLoadModule(hProcess: THandle; hFile: THandle; ImageName,
  458.   ModuleName: LPSTR; BaseOfDll, SizeOfDll: DWORD): Bool;
  459.  
  460. function SymUnloadModule(hProcess: THandle; BaseOfDll: DWORD): Bool;
  461.  
  462. function SymUnDName(sym: PImagehlpSymbol; UnDecName: LPSTR;
  463.   UnDecNameLength: DWORD): Bool;
  464.  
  465. function SymRegisterCallback(hProcess: THandle;
  466.   CallbackFunction: TSymbolRegisteredCallback; UserContext: Pointer): Bool;
  467.  
  468. { Image Integrity API's }
  469.  
  470. const
  471.   CERT_PE_IMAGE_DIGEST_DEBUG_INFO             = $01;
  472.   CERT_PE_IMAGE_DIGEST_RESOURCES              = $02;
  473.   CERT_PE_IMAGE_DIGEST_ALL_IMPORT_INFO        = $04;
  474.  
  475.   CERT_SECTION_TYPE_ANY                       = $FF;      { Any Certificate type }
  476.  
  477. type
  478.   TDigestHandle = Pointer;
  479.  
  480. type
  481.   TDigestFunction = function(refdata: TDigestHandle; pData: PByte;
  482.     dwLength: DWORD): Bool;
  483.  
  484. function ImageGetDigestStream(FileHandle: THandle; DigestLevel: DWORD;
  485.   DigestFunction: TDigestFunction; DigestHandle: TDigestHandle): Bool;
  486.  
  487. function ImageAddCertificate(FileHandle: THandle;
  488.   var Certificate: PWinCertificate; var Index: DWORD): Bool;
  489.  
  490. function ImageRemoveCertificate(FileHandle: THandle; Index: DWORD): Bool;
  491.  
  492. function ImageEnumerateCertificates(FileHandle: THandle; TypeFilter: Word;
  493.   var CertificateCount; Indices, IndexCount: PDWORD): Bool;
  494.  
  495. function ImageGetCertificateData(FileHandle: THandle; CertificateIndex: DWORD;
  496.   Certificate: PWinCertificate; var RequiredLength: DWORD): Bool;
  497.  
  498. function ImageGetCertificateHeader(FileHandle: THandle; CertificateIndex: DWORD;
  499.   var Certificateheader: PWinCertificate): Bool;
  500.  
  501. implementation
  502.  
  503. const
  504.   ImagehlpLib = 'IMAGEHLP.DLL';
  505.  
  506. function BindImage;                     external ImagehlpLib name 'BindImage';
  507. function BindImageEx;                   external ImagehlpLib name 'BindImageEx';
  508. function CheckSumMappedFile;            external ImagehlpLib name 'CheckSumMappedFile';
  509. function EnumerateLoadedModules;        external ImagehlpLib name 'EnumerateLoadedModules';
  510. function FindDebugInfoFile;             external ImagehlpLib name 'FindDebugInfoFile';
  511. function FindExecutableImage;           external ImagehlpLib name 'FindExecutableImage';
  512. function GetImageConfigInformation;     external ImagehlpLib name 'GetImageConfigInformation';
  513. function GetImageUnusedHeaderBytes;     external ImagehlpLib name 'GetImageUnusedHeaderBytes';
  514. function GetTimestampForLoadedLibrary;  external ImagehlpLib name 'GetTimestampForLoadedLibrary';
  515. function ImageAddCertificate;           external ImagehlpLib name 'ImageAddCertificate';
  516. function ImageDirectoryEntryToData;     external ImagehlpLib name 'ImageDirectoryEntryToData';
  517. function ImageEnumerateCertificates;    external ImagehlpLib name 'ImageEnumerateCertificates';
  518. function ImageGetCertificateData;       external ImagehlpLib name 'ImageGetCertificateData';
  519. function ImageGetCertificateHeader;     external ImagehlpLib name 'ImageGetCertificateHeader';
  520. function ImageGetDigestStream;          external ImagehlpLib name 'ImageGetDigestStream';
  521. function ImagehlpApiVersion;            external ImagehlpLib name 'ImagehlpApiVersion';
  522. function ImagehlpApiVersionEx;          external ImagehlpLib name 'ImagehlpApiVersionEx';
  523. function ImageLoad;                     external ImagehlpLib name 'ImageLoad';
  524. function ImageNtHeader;                 external ImagehlpLib name 'ImageNtHeader';
  525. function ImageRemoveCertificate;        external ImagehlpLib name 'ImageRemoveCertificate';
  526. function ImageRvaToSection;             external ImagehlpLib name 'ImageRvaToSection';
  527. function ImageRvaToVa;                  external ImagehlpLib name 'ImageRvaToVa';
  528. function ImageUnload;                   external ImagehlpLib name 'ImageUnload';
  529. function MakeSureDirectoryPathExists;   external ImagehlpLib name 'MakeSureDirectoryPathExists';
  530. function MapAndLoad;                    external ImagehlpLib name 'MapAndLoad';
  531. function MapDebugInformation;           external ImagehlpLib name 'MapDebugInformation';
  532. function MapFileAndCheckSumA;           external ImagehlpLib name 'MapFileAndCheckSumA';
  533. function MapFileAndCheckSumW;           external ImagehlpLib name 'MapFileAndCheckSumW';
  534. function MapFileAndCheckSum;           external ImagehlpLib name 'MapFileAndCheckSumA';
  535. function ReBaseImage;                   external ImagehlpLib name 'ReBaseImage';
  536. function RemovePrivateCvSymbolic;       external ImagehlpLib name 'RemovePrivateCvSymbolic';
  537. procedure RemoveRelocations;            external ImagehlpLib name 'RemoveRelocations';
  538. function SearchTreeForFile;             external ImagehlpLib name 'SearchTreeForFile';
  539. function SetImageConfigInformation;     external ImagehlpLib name 'SetImageConfigInformation';
  540. function SplitSymbols;                  external ImagehlpLib name 'SplitSymbols';
  541. function StackWalk;                     external ImagehlpLib name 'StackWalk';
  542. function SymCleanup;                    external ImagehlpLib name 'SymCleanup';
  543. function SymEnumerateModules;           external ImagehlpLib name 'SymEnumerateModules';
  544. function SymEnumerateSymbols;           external ImagehlpLib name 'SymEnumerateSymbols';
  545. function SymFunctionTableAccess;        external ImagehlpLib name 'SymFunctionTableAccess';
  546. function SymGetModuleBase;              external ImagehlpLib name 'SymGetModuleBase';
  547. function SymGetModuleInfo;              external ImagehlpLib name 'SymGetModuleInfo';
  548. function SymGetOptions;                 external ImagehlpLib name 'SymGetOptions';
  549. function SymGetSearchPath;              external ImagehlpLib name 'SymGetSearchPath';
  550. function SymGetSymFromAddr;             external ImagehlpLib name 'SymGetSymFromAddr';
  551. function SymGetSymFromName;             external ImagehlpLib name 'SymGetSymFromName';
  552. function SymGetSymNext;                 external ImagehlpLib name 'SymGetSymNext';
  553. function SymGetSymPrev;                 external ImagehlpLib name 'SymGetSymPrev';
  554. function SymInitialize;                 external ImagehlpLib name 'SymInitialize';
  555. function SymLoadModule;                 external ImagehlpLib name 'SymLoadModule';
  556. function SymRegisterCallback;           external ImagehlpLib name 'SymRegisterCallback';
  557. function SymSetOptions;                 external ImagehlpLib name 'SymSetOptions';
  558. function SymSetSearchPath;              external ImagehlpLib name 'SymSetSearchPath';
  559. function SymUnDName;                    external ImagehlpLib name 'SymUnDName';
  560. function SymUnloadModule;               external ImagehlpLib name 'SymUnloadModule';
  561. function TouchFileTimes;                external ImagehlpLib name 'TouchFileTimes';
  562. function UnDecorateSymbolName;          external ImagehlpLib name 'UnDecorateSymbolName';
  563. function UnMapAndLoad;                  external ImagehlpLib name 'UnMapAndLoad';
  564. function UnmapDebugInformation;         external ImagehlpLib name 'UnmapDebugInformation';
  565. function UpdateDebugInfoFile;           external ImagehlpLib name 'UpdateDebugInfoFile';
  566. function UpdateDebugInfoFileEx;         external ImagehlpLib name 'UpdateDebugInfoFileEx';
  567.  
  568. end.
  569.